import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'


const urlConfig = {
  '有效渠道管理列表': { url: '/qsb/channel/info/queryValChannel', method: 'post' }, // parentId
  '供应商三要素验证': { url: '/electron/tax/password/personalIdentity3', method: 'post' }, // parentId
  '供应商三要素及去重验证': { url: '/electron/tax/password/repeatAndIdentity3', method: 'post' }, // parentId
  '开票员关联企业-企业列表查询': { url: '/electron/issuer/addEntFindDrawerList', method: 'post' },
  '校验电子税务局密码 + 响应数组结果': { url: '/electron/tax/password/verifyElePassword', method: 'post' },
  '保存开票人': { url: '/electron/tax/password/saveEleIssuer', method: 'post' },
  '开票员详情': { url: '/electron/issuer/drawerDetails', method: 'get' },
  '关联企业停用': { url: '/electron/tax/password/deactivateElePassword', method: 'get' },
  '关联企业启用': { url: '/electron/tax/password/enableElePassword', method: 'post' },
  '开票员详情关联的企业信息': { url: '/electron/issuer/drawerDetailsRelEnt', method: 'get' },
  '停用开票人': { url: '/electron/tax/password/deactivateEleIssuer', method: 'post' },
  '开票人下拉列表查询': { url: '/electron/issuer/pullDownDrawerList', method: 'post' },
  '查询未绑定开票员的企业,查询未绑定内部员工或者渠道': { url: '/electron/issuer/findDrawerBand', method: 'post' },
  '启用开票人': { url: '/electron/tax/password/enableEleIssuer', method: 'get' },
  '添加关联企业': { url: '/electron/tax/password/addElePassword', method: 'post' },
  '修改开票人': { url: '/electron/tax/password/updateEleIssuer', method: 'post' },

}

const actionType = {
    get: (url, parameter) => {
        return getAction(url, parameter)
    },
    post: (url, parameter) => {
        return postAction(url, parameter)
    },
    put: (url, parameter) => {
        return putAction(url, parameter)
    },
    delete: (...args) => {
        return deleteAction(...args)
    },
    http: (url, parameter, method) => {
        return httpAction(url, parameter, method)
    },
}

export default (key, ...args) => {
    const tempConfig = urlConfig[key]
    let url =tempConfig.url
    if(tempConfig.isPost && tempConfig.isPost===true){
      const ll = []
      Object.keys(args[0]).forEach(key=>{
        ll.push(`${key}=${args[0][key]}`)
      })
      url += "?"+ll.join('&')
    }
    return actionType[tempConfig.method](url, ...args)
}
